return value->value;
}
+/* PangoStretch */
+
+static const GtkCssValueClass GTK_CSS_VALUE_FONT_STRETCH = {
+ gtk_css_value_enum_free,
+ gtk_css_value_enum_compute,
+ gtk_css_value_enum_equal,
+ gtk_css_value_enum_transition,
+ gtk_css_value_enum_print
+};
+
+static GtkCssValue font_stretch_values[] = {
+ { >K_CSS_VALUE_FONT_STRETCH, 1, PANGO_STRETCH_ULTRA_CONDENSED, "ultra-condensed" },
+ { >K_CSS_VALUE_FONT_STRETCH, 1, PANGO_STRETCH_EXTRA_CONDENSED, "extra-condensed" },
+ { >K_CSS_VALUE_FONT_STRETCH, 1, PANGO_STRETCH_CONDENSED, "condensed" },
+ { >K_CSS_VALUE_FONT_STRETCH, 1, PANGO_STRETCH_SEMI_CONDENSED, "semi-condensed" },
+ { >K_CSS_VALUE_FONT_STRETCH, 1, PANGO_STRETCH_NORMAL, "normal" },
+ { >K_CSS_VALUE_FONT_STRETCH, 1, PANGO_STRETCH_SEMI_EXPANDED, "semi-expanded" },
+ { >K_CSS_VALUE_FONT_STRETCH, 1, PANGO_STRETCH_EXPANDED, "expanded" },
+ { >K_CSS_VALUE_FONT_STRETCH, 1, PANGO_STRETCH_EXTRA_EXPANDED, "extra-expanded" },
+ { >K_CSS_VALUE_FONT_STRETCH, 1, PANGO_STRETCH_ULTRA_EXPANDED, "ultra-expanded" },
+};
+
+GtkCssValue *
+_gtk_css_font_stretch_value_new (PangoStretch font_stretch)
+{
+ g_return_val_if_fail (font_stretch < G_N_ELEMENTS (font_stretch_values), NULL);
+
+ return _gtk_css_value_ref (&font_stretch_values[font_stretch]);
+}
+
+GtkCssValue *
+_gtk_css_font_stretch_value_try_parse (GtkCssParser *parser)
+{
+ guint i;
+
+ g_return_val_if_fail (parser != NULL, NULL);
+
+ for (i = 0; i < G_N_ELEMENTS (font_stretch_values); i++)
+ {
+ if (_gtk_css_parser_try (parser, font_stretch_values[i].name, TRUE))
+ return _gtk_css_value_ref (&font_stretch_values[i]);
+ }
+
+ return NULL;
+}
+
+PangoStretch
+_gtk_css_font_stretch_value_get (const GtkCssValue *value)
+{
+ g_return_val_if_fail (value->class == >K_CSS_VALUE_FONT_STRETCH, PANGO_STRETCH_NORMAL);
+
+ return value->value;
+}
+
/* GtkCssArea */
static const GtkCssValueClass GTK_CSS_VALUE_AREA = {
GtkCssValue * _gtk_css_font_weight_value_try_parse (GtkCssParser *parser);
PangoWeight _gtk_css_font_weight_value_get (const GtkCssValue *value);
+GtkCssValue * _gtk_css_font_stretch_value_new (PangoStretch stretch);
+GtkCssValue * _gtk_css_font_stretch_value_try_parse (GtkCssParser *parser);
+PangoStretch _gtk_css_font_stretch_value_get (const GtkCssValue *value);
+
GtkCssValue * _gtk_css_area_value_new (GtkCssArea area);
GtkCssValue * _gtk_css_area_value_try_parse (GtkCssParser *parser);
GtkCssArea _gtk_css_area_value_get (const GtkCssValue *value);
* font-size: 12px;
* ]|
*
- * ## font: [family] [style] [variant] [size];
+ * ## font-stretch: [face]
+ *
+ * Selects a normal, condensed, or expanded face from a font family.
+ *
+ * Absolute keyword values have the following ordering, from narrowest to widest:
+ *
+ * - ultra-condensed
+ * - extra-condensed
+ * - condensed
+ * - semi-condensed
+ * - normal
+ * - semi-expanded
+ * - expanded
+ * - extra-expanded
+ * - ultra-expanded
+ *
+ * ## font: [family] [style] [variant] [stretch] [size];
*
* A shorthand for setting a few font properties at once.
* - Supports any format accepted by pango_font_description_from_string()
{
values[3] = _gtk_css_font_weight_value_new (pango_font_description_get_weight (desc));
}
+ if (mask & PANGO_FONT_MASK_STRETCH)
+ {
+ values[4] = _gtk_css_font_stretch_value_new (pango_font_description_get_stretch (desc));
+ }
if (mask & PANGO_FONT_MASK_SIZE)
{
- values[4] = _gtk_css_number_value_new ((double) pango_font_description_get_size (desc) / PANGO_SCALE, GTK_CSS_PX);
+ values[5] = _gtk_css_number_value_new ((double) pango_font_description_get_size (desc) / PANGO_SCALE, GTK_CSS_PX);
}
pango_font_description_free (desc);
g_value_unset (&v);
}
+ if (mask & PANGO_FONT_MASK_STRETCH)
+ {
+ g_value_init (&v, PANGO_TYPE_STRETCH);
+ g_value_set_enum (&v, pango_font_description_get_stretch (description));
+
+ prop = _gtk_style_property_lookup ("font-stretch");
+ _gtk_style_property_assign (prop, props, state, &v);
+ g_value_unset (&v);
+ }
+
if (mask & PANGO_FONT_MASK_SIZE)
{
g_value_init (&v, G_TYPE_DOUBLE);
if (v)
pango_font_description_set_weight (description, _gtk_css_font_weight_value_get (v));
+ v = (* query_func) (_gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("font-stretch"))), query_data);
+ if (v)
+ pango_font_description_set_stretch (description, _gtk_css_font_stretch_value_get (v));
+
g_value_init (value, PANGO_TYPE_FONT_DESCRIPTION);
g_value_take_boxed (value, description);
}
_gtk_css_shorthand_property_init_properties (void)
{
/* The order is important here, be careful when changing it */
- const char *font_subproperties[] = { "font-family", "font-style", "font-variant", "font-weight", "font-size", NULL };
+ const char *font_subproperties[] = { "font-family", "font-style", "font-variant", "font-weight", "font-stretch", "font-size", NULL };
const char *margin_subproperties[] = { "margin-top", "margin-right", "margin-bottom", "margin-left", NULL };
const char *padding_subproperties[] = { "padding-top", "padding-right", "padding-bottom", "padding-left", NULL };
const char *border_width_subproperties[] = { "border-top-width", "border-right-width", "border-bottom-width", "border-left-width", NULL };
return _gtk_css_font_variant_value_new (g_value_get_enum (value));
}
+static GtkCssValue *
+parse_pango_stretch (GtkCssStyleProperty *property,
+ GtkCssParser *parser)
+{
+ GtkCssValue *value = _gtk_css_font_stretch_value_try_parse (parser);
+
+ if (value == NULL)
+ _gtk_css_parser_error (parser, "unknown value for property");
+
+ return value;
+}
+
+static void
+query_pango_stretch (GtkCssStyleProperty *property,
+ const GtkCssValue *css_value,
+ GValue *value)
+{
+ g_value_init (value, PANGO_TYPE_STRETCH);
+ g_value_set_enum (value, _gtk_css_font_stretch_value_get (css_value));
+}
+
+static GtkCssValue *
+assign_pango_stretch (GtkCssStyleProperty *property,
+ const GValue *value)
+{
+ return _gtk_css_font_stretch_value_new (g_value_get_enum (value));
+}
+
static GtkCssValue *
parse_border_style (GtkCssStyleProperty *property,
GtkCssParser *parser)
query_pango_weight,
assign_pango_weight,
_gtk_css_font_weight_value_new (PANGO_WEIGHT_NORMAL));
+ gtk_css_style_property_register ("font-stretch",
+ GTK_CSS_PROPERTY_FONT_STRETCH,
+ PANGO_TYPE_STRETCH,
+ GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_AFFECTS_FONT,
+ parse_pango_stretch,
+ query_pango_stretch,
+ assign_pango_stretch,
+ _gtk_css_font_stretch_value_new (PANGO_STRETCH_NORMAL));
gtk_css_style_property_register ("text-shadow",
GTK_CSS_PROPERTY_TEXT_SHADOW,
GTK_CSS_PROPERTY_FONT_STYLE,
GTK_CSS_PROPERTY_FONT_VARIANT,
GTK_CSS_PROPERTY_FONT_WEIGHT,
+ GTK_CSS_PROPERTY_FONT_STRETCH,
GTK_CSS_PROPERTY_TEXT_SHADOW,
GTK_CSS_PROPERTY_ICON_SOURCE,
GTK_CSS_PROPERTY_ICON_SHADOW,
* {
font-family: "Sans";
font-size: 15px;
+ font-stretch: normal;
font-style: normal;
font-variant: normal;
font-weight: normal;
* {
font-family: "Sans";
font-size: 15px;
+ font-stretch: normal;
font-style: normal;
font-variant: normal;
font-weight: normal;
* {
font-family: initial;
font-size: initial;
+ font-stretch: normal;
font-style: normal;
font-variant: normal;
font-weight: bold;
* {
font-family: "Sans";
font-size: 15px;
+ font-stretch: normal;
font-style: normal;
font-variant: normal;
font-weight: normal;
border-top-width: inherit;
font-family: inherit;
font-size: inherit;
+ font-stretch: inherit;
font-style: inherit;
font-variant: inherit;
font-weight: inherit;
engine: inherit;
font-family: inherit;
font-size: inherit;
+ font-stretch: inherit;
font-style: inherit;
font-variant: inherit;
font-weight: inherit;
border-top-width: initial;
font-family: initial;
font-size: initial;
+ font-stretch: initial;
font-style: initial;
font-variant: initial;
font-weight: initial;